using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class TestModel:ModelBase{
    private static TestModel instance;
    public static TestModel Instance
    {
        get
        {
            if (instance == null)
            {
                instance = new TestModel();
            }
            return instance;
        }
    }
	public string code;
    /**
    *每次序列化都会调用构造函数，不能把事件监听放在里面，不然会造成多次监听
    */
    private TestModel()
    {
        
    }
    public void Init(){
        //不能放构造函数进行处理，否则json解析的时候会造成多次调用构造函数，多次监听
        Dispatcher.Instance.AddEventListener(GMConfig.EventType.NCExchangeCodeChange, DataChange);
    }
    public void DataChange(object data){
        var _data = (TestModel)System.Convert.ChangeType(data,typeof(TestModel));
        set("code",_data.code);
        Debug.Log("Datachange");
    }
}